﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Repositories;
using Repositories.Interfaces;
using System.Globalization;

namespace AsiaSnackExpress
{
    public partial class ListCategoriesControl : System.Web.UI.UserControl
    {

        ICategoryRepository _categoryRep;
        public ICategoryRepository CategoryRep
        {
            get
            {
                if (_categoryRep == null)
                {
                    _categoryRep = DIHelper.Resolve<ICategoryRepository>();
                }
                return _categoryRep;
            }

        }


        public List<Category> CategoryDataSource
        {
            get
            {
                return (List<Category>)gridCategories.DataSource;
            }
            set
            {
                if (value != null && value.Count > 0)
                {
                    gridCategories.DataSource = value;
                    gridCategories.DataBind();
                }
                else
                    this.Visible = false;
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                CategoryDataSource = CategoryRep.GetAllCategory();

        }
    }
}